//
//  YZCityController.m
//  天气预报
//
//  Created by jacoy on 16/5/4.
//  Copyright © 2016年 jacoy. All rights reserved.
//

#import "YZCityController.h"
#import "YZLoadWeatherViewModel.h"

static NSString *cityIdentifier = @"cityIdentifier";

@interface YZCityController ()

@end

@implementation YZCityController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.title = @"请选择城市";

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.cities.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cityIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cityIdentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = self.cities[indexPath.item];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *city = self.cities[indexPath.item];
    

    [YZLoadWeatherViewModel loadWeather:city];
    [self.navigationController popToRootViewControllerAnimated:NO];
}


@end
